#-*-coding:utf-8-*-

def test(n):
    try:
        if n == 0:
            raise NameError()
        elif n == 1:
            raise KeyError()
        elif n == 2:
            raise IndexError()
        else:
            raise Exception()
    except (IndexError, KeyError) as ex:
        print type(ex)
    except NameError:
        print "NameError"
    except:
        print "Exception"
        
if __name__ == '__main__':
    test(0)
    test(1)
    test(2)
    test(3)